local hj_tiandao = fk.CreateSkill {
  name = "hj_tiandao",
  tags = { Skill.Compulsory, },
}


hj_tiandao:addEffect(fk.TurnStart, {
  anim_type = "support",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(hj_tiandao.name) and player == target
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local judge = {
      who = player,
      reason = hj_tiandao.name,
    }
    room:judge(judge)
    if not judge.card then return end
    if judge.card.color == Card.Red then
      if #player.player_cards[Player.Hand] == 0 or not player:isWounded() then return end
      local cids = room:askToDiscard(player,{
        min_num = 1,
        max_num = 1,
        include_equip = false,
        skill_name = hj_tiandao.name,
        cancelable = true,
        pattern = ".|.|".."heat,diamond".."|.|.|.",
      })
      if cids and #cids > 0 then
        room:recover({
          who = player,
          num = 1,
          recoverBy = player,
          skillName = hj_tiandao.name
        }) 
      end
    else
      room:obtainCard(player, judge.card, true, fk.ReasonJustMove, player, hj_tiandao.name)
      room:loseHp(player,1,hj_tiandao.name)
    end
  end,
})


return hj_tiandao